



// 只支持rotateBy

let Action = require('./action');

class RotateBy extends  Action{
    constructor(d,angle){
        super();
        this.duration = d;
        this._degressDelta = angle;
    }

    start() {
        super.start();
        this._startDegress = this.target.degress;
    }

    update(t) {
        if(this.target.visible && this.target.enabled){
            this.target.degress = this._startDegress + t * this._degressDelta;
        }
    }
}

class RotateTo extends RotateBy{
    constructor(d,angle) {
        super(d,angle);
    }

    start() {
        super.start();
        this._deltaAngle = this._degressDelta - this._startDegress;

    }
    update(t) {
        if(this.target.visible && this.target.enabled){
            this.target.degress = this._startDegress + t * this._deltaAngle;
        }
    }
}

module.exports = {
    RotateBy:RotateBy,
    RotateTo:RotateTo
};
